﻿var eZhanNikeTitle="亲爱的";
var eZhanWelcomeTo="用户,欢迎您的光临";
var eZhanInvite="邀请您在线洽谈";
var eZhanTalk="接受对话";
var eZhanClearTaltk="暂不对话";
function GetLanguageText()
{
    var ln=GetRequest("ln").replace("ln=","");
    switch(ln)
    {
       case "ar-sa"://阿拉伯语
            eZhanNikeTitle="عزيز";
            eZhanWelcomeTo="شاهد,نرحب بك لزيارة";
            eZhanInvite="أدعوكم إلى التحدث على الانترنت"
            eZhanTalk="قبول الحوار";
            eZhanClearTaltk="إلغاء الحوار";
            break;
       case "de-de"://德语
            eZhanNikeTitle="Lieb";
            eZhanWelcomeTo="Benutzer,Willkommen auf Ihren Besuch";
            eZhanInvite="Laden Sie zu sprechen online"
            eZhanTalk="Akzeptiert";
            eZhanClearTaltk="Abbrechen";
            break;
       case "en-us"://英语
            eZhanNikeTitle="Dear";
            eZhanWelcomeTo="Users,Welcome to your visit";
            eZhanInvite="Invite you to talk online"
            eZhanTalk=" Accepted";
            eZhanClearTaltk="Cancel";

            break;
       case "ja-jp"://日语
            eZhanNikeTitle="親愛なる";
            eZhanWelcomeTo="ユーザー,ようこそあなたを訪問する";
            eZhanInvite="招待してオンラインで話をする"
            eZhanTalk="抱擁の対話";
            eZhanClearTaltk="キャンセルのダイアログ";
            break;
       case "zh-tw"://繁体
            eZhanNikeTitle="親愛的";
            eZhanWelcomeTo="用戶,歡迎您的光臨";
            eZhanInvite="邀請您在線洽談"
            eZhanTalk="接受對話";
            eZhanClearTaltk="暫不對話";
            break;
    }
}
//得到url参数
function GetRequest(para) 
{ 
    var   i; 
    var   searchString=location.search;
    para = para.toLowerCase(); 
    searchString=searchString.toLowerCase(); 

    var   pos=searchString.indexOf( "?"); 
    if (pos==0) 
    { 
        var str,str1,arr,strpos; 
        arr=searchString.split( '&'); 
        for   (i=0;i <=arr.length-1;i++) 
        { 
            str =   arr[i]; 
            strpos =   str.indexOf(para); 
            if   (strpos!=-1) 
            return str.replace( "?", ""); 
        } 
    } 
    return   " "; 
}

 var init_pos= 0; 
 var last_pos= 0;
function floatDialogFormInit(userName,welcomeInfo, webName, nickName)
{
    GetLanguageText();
    var floatDialogForm ;
    floatDialogForm = "<div id=\"DivParent\" style=\"position: absolute; font-size: 12px; width:483px; cursor: move;\"  onMouseDown=\"catchFlyBar(this)\" onMouseUp=\"releaseFlyBar(this)\">";
    floatDialogForm += "<div style=\"float: left; width: 16px; height: 168px; background-image: url(http://www.superstat.cn/Images/oodline_left.jpg);\"></div>";
    floatDialogForm += "<div style=\"float: left; width: 450px; height: 168px; background-image: url(http://www.superstat.cn/Images/oodline_bg.gif);\">";
    floatDialogForm += "<table style=\"width: 100%; height: 100px;font-size:12px;\" border='0' cellspacing='0' cellpadding='0' valign=\"middle\">";
    floatDialogForm += "<tr style=\"height: 28px; font-weight:700; color:white;\"><td><div style=\"float:left;width:350px;text-align:left; \">"+eZhanNikeTitle+userName+eZhanWelcomeTo+"! &nbsp;&nbsp;</div><div style=\"float:left; text-algin:right;\">易展叮当</div></td></tr>";
    floatDialogForm += "<tr><td style=\"height:20px;text-align:left\">&nbsp;&nbsp;"+webName+"的"+nickName+eZhanInvite+":</td></tr>";
    floatDialogForm += "<tr><td style=\"height: 70px;text-align:left\" valign=\"top\">&nbsp;&nbsp;&nbsp;&nbsp;"+welcomeInfo+"</td></tr>";
    floatDialogForm += "</table>";
    floatDialogForm += "<div  style=\"width: 450px; height: 20px;text-align: right;\">";
    floatDialogForm += "<div title=\"\" style=\"float:right;width: 62px; height: 19px; line-height:21px;text-align: center;margin-right:16px;cursor: hand;color:#143C81;background-image: url(http://www.superstat.cn/Images/Invite1.jpg);\"  onclick='javascript:InviteCloseWindow("+userId+");'>"+eZhanClearTaltk+"</div>";
    floatDialogForm += "<div title=\"\" style=\"float:right; width: 62px; height: 19px;line-height:21px;text-align: center;margin-right:16px;cursor: hand;color:#143C81;background-image: url(http://www.superstat.cn/Images/Invite2.jpg);\" onclick='javascript:InviteOpenChatroom("+userId+");'>"+eZhanTalk+"</div>";
    floatDialogForm += "</div></div>";
    floatDialogForm += "<div style=\"float: left; width: 16px; height: 168px; background-image: url(http://www.superstat.cn/Images/oodline_right.jpg);\"></div>";
    floatDialogForm += "</div>";
    
    document.write(floatDialogForm);
    
    var divParent = document.getElementById('DivParent');
    divParent.style.left = document.documentElement.clientWidth/2-172;
    divParent.style.top = document.documentElement.clientHeight/2-79;
    init_pos=last_pos=divParent.style.posTop;
}
function floatDialogFormDefine(userName,welcomeInfo, webName, nickName,userId,lng)
{
    GetLanguageText();
    if ( document.getElementById("DivParent") == null )
    {
        var divDefine = document.createElement("div") ;
        divDefine.id = "DivParent" ;
        divDefine.style.fontSize="12px";
        divDefine.style.position = "absolute";
        divDefine.style.cursor = "move";
        divDefine.style.width="483px";
        divDefine.style.zIndex = "999";
        divDefine.style.left = document.documentElement.offsetWidth/2-172;
        divDefine.style.top = document.documentElement.offsetHeight/2-79;
     
        divDefine.onmousedown = catchFlyBar;
        divDefine.onmouseup = releaseFlyBar;
        var str = "<div style=\"float: left; width: 16px; height: 168px; background-image: url(http://www.superstat.cn/Images/oodline_left.jpg);\"></div>";
        str += "<div style=\"float: left; width: 450px; height: 168px; background-image: url(http://www.superstat.cn/Images/oodline_bg.gif);\">";
        str += "<table style=\"width: 100%; height: 100px;font-size:12px;\" border='0' cellspacing='0' cellpadding='0' valign=\"middle\">";
        str += "<tr style=\"height: 28px; font-weight:700; color:white;\"><td><div style=\"float:left;width:350px;text-align:left;\">"+eZhanNikeTitle+userName+eZhanWelcomeTo+"! &nbsp;&nbsp;</div><div style=\"float:left; text-algin:right;\">易展叮当</div></td></tr>";
        str += "<tr><td style=\"height:20px;text-align:left\">&nbsp;&nbsp;"+webName+"的"+nickName+eZhanInvite+":</td></tr>";
        str += "<tr><td style=\"height: 70px;text-align:left\" valign=\"top\">&nbsp;&nbsp;&nbsp;&nbsp;"+welcomeInfo+"</td></tr>";
        str += "</table>";
        str += "<div  style=\"width: 450px; height: 20px;text-align: right;\">";
        str += "<div title=\"\" style=\"float:right;width: 62px; height: 19px; line-height:21px;text-align: center;margin-right:16px;cursor: hand;color:#143C81;background-image: url(http://www.superstat.cn/Images/Invite1.jpg);\"  onclick='javascript:InviteCloseWindow("+userId+");'>"+eZhanClearTaltk+"</div>";
        str += "<div title=\"\" style=\"float:right; width: 62px; height: 19px;line-height:21px;text-align: center;margin-right:16px;cursor: hand;color:#143C81;background-image: url(http://www.superstat.cn/Images/Invite2.jpg);\" onclick='javascript:InviteOpenChatroom("+userId+");'>"+eZhanTalk+"</div>";
        str += "</div></div>";
        str += "<div style=\"float: left; width: 16px; height: 168px; background-image: url(http://www.superstat.cn/Images/oodline_right.jpg);\"></div>";
        
        divDefine.innerHTML = str;
        document.body.insertBefore(divDefine,null);
        init_pos=last_pos=document.getElementById('DivParent').style.posTop;
    }
    else
    {
        
    }

}

var bIsCatchFlyBar = false;   
var dragClickX = 0;   
var dragClickY = 0; 

function catchFlyBar(e){
    var divParent = document.getElementById('DivParent');
    bIsCatchFlyBar = true;   
    var x=event.x+document.body.scrollLeft;   
    var y=event.y+document.body.scrollTop;
    dragClickX=x-divParent.style.pixelLeft;   
    dragClickY=y-divParent.style.pixelTop;   
    document.getElementById('DivParent').setCapture();   
    document.onmousemove = moveFlyBar;   
}   
  
function releaseFlyBar(e){  
    bIsCatchFlyBar = false;
    document.getElementById('DivParent').releaseCapture();   
    document.onmousemove = null;
}   
function moveFlyBar(e){   
    if(bIsCatchFlyBar){
        var divParent = document.getElementById('DivParent');
        var clientWidth = document.body.clientWidth;
        var clientHeight = document.body.clientHeight;
        var scrollLeft=document.body.scrollLeft;
        var scrollTop=document.body.scrollTop;
             
        var divLeft=event.x+scrollLeft-dragClickX;
        var divTop=event.y+scrollTop-dragClickY;

        if(divLeft>0){
            if(divLeft+483>clientWidth + scrollLeft ){
                divParent.style.left = clientWidth + scrollLeft -483;
            }
            else{
                divParent.style.left = divLeft
            }
        }
        else{
            divParent.style.left = 0;
        }
        
        if(divTop>0){
            if(divTop+168>clientHeight + scrollTop ){
                divParent.style.top = clientHeight + scrollTop -168;
            }
            else{
                divParent.style.top = divTop;
            }
        }
        else{
            divParent.style.top = 0;
        }
    }
}  


function myload_flybar(){
    if(document.getElementById('DivParent')){
        var target_pos=document.documentElement.scrollTop+init_pos;
        var step=(target_pos-last_pos)/10|0 ;
        document.getElementById("DivParent").style.posTop+=step ;
        last_pos+=step;
    }
    
} 
window.onresize = myload_flybar;   
window.onscroll = myload_flybar;

function floatDialogFormClose()
{
	//document.getElementById("DivParent").style.display = "none";
	document.body.removeChild(document.getElementById("DivParent"))
};